local L = {}

-- Default localization
L["Custom text"] = true
L["Don't show anything for items that are not known"] = true
L["Don't show anything for items that cannot be sold to a vendor"] = true
L["General"] = true
L["Ignore unknown items"] = true
L["Ignore unsellable items"] = true
L["Modifier key only"] = true
L["modifier.any"] = "Any"
L["Only show price when a modifier key is held down"] = true
L["Prices in library: %d"] = true
L["Purge prices!"] = true
L["Purge recorded vendor prices"] = true
L["Record vendor prices"] = true
L["Recorded vendor prices: %d"] = true
L["Sells for"] = true
L["Show price for bag slots"] = true
L["Show statistics for stored prices"] = true
L["Show statistics"] = true
L["Specify a custom text to display instead of 'Sells for'."] = true
L["Text color"] = true
L["Unknown sell price"] = true
L["Display style"] = true
L["Select the display style"] = true
L["Coins"] = true
L["Text only"] = true
L["Price data"] = true
L["coin.gold"] = "g"
L["coin.silver"] = "s"
L["coin.copper"] = "c"
L["Charge"] = true  -- Must match the tooltip text for items with 1 charge!
L["Charges"] = true  -- Must match the tooltip text for items with 2 or more charges!


local GameLocale = GetLocale()

-- Translators, there are some unused translations from older versions. Feel free to remove them if you discover any.
-- I do plan to make a script to quickly weed them out at some point.

if GameLocale == "zhCN" then
  -- Reistlin Hotfix
  L["Custom text"] = "自定义文字"
  L["Don't show anything for items that are not known"] = "不显示所有未知物品"
  L["Don't show anything for items that cannot be sold to a vendor"] = "不显示无法出售物品"
  L["General"] = "基本设置"
  L["Ignore unknown items"] = "忽略所有未知物品"
  L["Ignore unsellable items"] = "忽略无法出售物品"
  L["Modifier key only"] = "辅助键显示"
  L["modifier.any"] = "任意键"
  L["Only show price when a modifier key is held down"] = "按下辅助键时显示物品价格"
  L["Prices in library: %d"] = "ItemPrice Database: %d"
  L["Purge prices!"] = "清除物品数据"
  L["Purge recorded vendor prices"] = "清除数据库记录的物品价格"
  L["Record vendor prices"] = "记录物品价格"
  L["Recorded vendor prices: %d"] = "ItemPrice Recorded: %d"
  L["Sells for"] = "售价"
  L["Show price for bag slots"] = "显示背包栏位价格"
  L["Show statistics for stored prices"] = "显示物品价格统计"
  L["Show statistics"] = "显示统计"
  L["Specify a custom text to display instead of 'Sells for'."] = "用自定义文本取代默认显示的[售价]"
  L["Text color"] = "文字颜色"
  L["Unknown sell price"] = "暂无数据"
  L["Display style"] = "显示方式"
  L["Select the display style"] = "选择显示样式"
  L["Coins"] = "显示图标"
  L["Text only"] = "显示文字"
  L["Price data"] = "价格数据"
  L["coin.gold"] = "金"
  L["coin.silver"] = "银"
  L["coin.copper"] = "铜"

elseif GameLocale == "zhTW" then
  -- Reistlin Hotfix
  L["Custom text"] = "自定義文字"
  L["Don't show anything for items that are not known"] = "不顯示所有未知物品"
  L["Don't show anything for items that cannot be sold to a vendor"] = "不顯示無法出售物品"
  L["General"] = "基本設置"
  L["Ignore unknown items"] = "忽略所有未知物品"
  L["Ignore unsellable items"] = "忽略無法出售物品"
  L["Modifier key only"] = "輔助鍵顯示"
  L["modifier.any"] = "任意鍵"
  L["Only show price when a modifier key is held down"] = "按下輔助鍵時顯示物品價格"
  L["Prices in library: %d"] = "ItemPrice Database: %d"
  L["Purge prices!"] = "清除物品數據"
  L["Purge recorded vendor prices"] = "清除數據庫記錄的物品價格"
  L["Record vendor prices"] = "記錄物品價格"
  L["Recorded vendor prices: %d"] = "ItemPrice Recorded: %d"
  L["Sells for"] = "售價"
  L["Show price for bag slots"] = "顯示背包欄位價格"
  L["Show statistics for stored prices"] = "顯示物品價格統計"
  L["Show statistics"] = "顯示統計"
  L["Specify a custom text to display instead of 'Sells for'."] = "用自定義文本取代默認顯示的[售價]"
  L["Text color"] = "文字顏色"
  L["Unknown sell price"] = "暫無數據"
  L["Display style"] = "顯示方式"
  L["Select the display style"] = "選擇顯示樣式"
  L["Coins"] = "顯示圖標"
  L["Text only"] = "顯示文字"
  L["Price data"] = "價格數據"
  L["coin.gold"] = "金"
  L["coin.silver"] = "銀"
  L["coin.copper"] = "銅"

end

for key, text in pairs(L) do
  if text == true then L[key] = key end
end

_G.ItemPriceTooltip_Locale = setmetatable(L, {
  __newindex = function() error("Attempt to write to the locale table!", 2) end,
  __index = function(self, key)
    if key == nil then error("Key was nil!", 2) end
    geterrorhandler()("Unknown key: "..tostring(key))
    rawset(self, key, key)
    return key
  end,
})

